package com.ktgj.hotel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.hotel.domain.HotelOrderOperation;
import com.ktgj.hotel.service.IHotelOrderOperationService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 酒店订单信息操作Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@ControllerAdvice
@RestController
@RequestMapping("/operation")
public class HotelOrderOperationController extends BaseController
{
    @Autowired
    private IHotelOrderOperationService hotelOrderOperationService;

    /**
     * 查询酒店订单信息操作列表
     */
    @PreAuthorize(hasPermi = "hotel:operation:list")
    @GetMapping("/list")
    public TableDataInfo list(HotelOrderOperation hotelOrderOperation)
    {
        startPage();
        List<HotelOrderOperation> list = hotelOrderOperationService.selectHotelOrderOperationList(hotelOrderOperation);
        return getDataTable(list);
    }

    /**
     * 导出酒店订单信息操作列表
     */
    @PreAuthorize(hasPermi = "hotel:operation:export")
    @Log(title = "酒店订单信息操作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelOrderOperation hotelOrderOperation) throws IOException
    {
        List<HotelOrderOperation> list = hotelOrderOperationService.selectHotelOrderOperationList(hotelOrderOperation);
        ExcelUtil<HotelOrderOperation> util = new ExcelUtil<HotelOrderOperation>(HotelOrderOperation.class);
        util.exportExcel(response, list, "酒店订单信息操作数据");
    }

    /**
     * 获取酒店订单信息操作详细信息
     */
    @PreAuthorize(hasPermi = "hotel:operation:query")
    @GetMapping(value = "/{operationid}")
    public AjaxResult getInfo(@PathVariable("operationid") Long operationid)
    {
        return AjaxResult.success(hotelOrderOperationService.selectHotelOrderOperationById(operationid));
    }

    /**
     * 新增酒店订单信息操作
     */
    @PreAuthorize(hasPermi = "hotel:operation:add")
    @Log(title = "酒店订单信息操作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelOrderOperation hotelOrderOperation)
    {
        return toAjax(hotelOrderOperationService.insertHotelOrderOperation(hotelOrderOperation));
    }

    /**
     * 修改酒店订单信息操作
     */
    @PreAuthorize(hasPermi = "hotel:operation:edit")
    @Log(title = "酒店订单信息操作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelOrderOperation hotelOrderOperation)
    {
        return toAjax(hotelOrderOperationService.updateHotelOrderOperation(hotelOrderOperation));
    }

    /**
     * 删除酒店订单信息操作
     */
    @PreAuthorize(hasPermi = "hotel:operation:remove")
    @Log(title = "酒店订单信息操作", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operationids}")
    public AjaxResult remove(@PathVariable Long[] operationids)
    {
        return toAjax(hotelOrderOperationService.deleteHotelOrderOperationByIds(operationids));
    }
}
